{include file="public/top"}
<article class="page-container">
    <form class="form-horizontal" role="form" action="" method="post">
        <input type="hidden" name="id" value="{$authgroups.id}" />
        <div class="row cl" style="padding-top:20px;margin-left:40px;">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span>用户组名称：
            </label>
            <div class="formControls col-xs-8 col-sm-4">
                <input type="text" class="input-text" value="{$authgroups.title}" placeholder="" id="title" name="title">
            </div>
        </div>
        <div class="row cl" style="padding-top:20px;margin-left:40px;">
            <label for="group_id" class="form-label col-xs-4 col-sm-3" >
                <span class="c-red">*</span>启用状态：
            </label>
            <div class="formControls col-xs-8 col-sm-4">
                <input class="input-text" name="status" value="1" {if condition="$authgroups['status'] eq 1"}checked="checked"{/if} checked="checked" type="checkbox">
            </div>
        </div>
    
        <div class="row cl" style="padding-top:20px;margin-left:40px;">
            <label class="form-label col-xs-4 col-sm-3">配置权限：</label>
            <div class="formControls col-xs-8 col-sm-9"> 
                <span class="select-box" style="width:500px;">
                    {volist name="authRuleRes" id="authRule"}
                        <tr>
                            <td>
                                <label>
                                    <?php echo str_repeat('&nbsp;', $authRule['level']*3);?>
                                    <input name="rules[]" value="{$authRule.id}"
                                    <?php $arr=explode(',', $authgroups['rules']); if(in_array($authRule['id'], $arr)){echo 'checked="checked"';} ?>
                                    dataid="id-{$authRule.dataid}" class="inverted checkbox-parent {if condition="$authRule['level'] neq 0"} checkbox-child {/if} " type="checkbox">
                                    <span {if condition="$authRule['level'] eq 0"} style="font-weight:bold; font-size:14px;" {/if} class="text">{$authRule.title}</span>
                                </label>
                            </td>
                        </tr>
                    {/volist}
                </span> 
            </div>
        </div>

        <div class="row cl" style="padding-top:20px;margin-left:40px;">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__admin__/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="__admin__/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="__admin__/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript">
/* 权限配置 */
$(function () {
    //动态选择框，上下级选中状态变化
    $('input.checkbox-parent').on('change', function () {
        var dataid = $(this).attr("dataid");
        $('input[dataid^=' + dataid + ']').prop('checked', $(this).is(':checked'));
    });
    $('input.checkbox-child').on('change', function () {
        var dataid = $(this).attr("dataid");
        dataid = dataid.substring(0, dataid.lastIndexOf("-"));
        var parent = $('input[dataid=' + dataid + ']');
        if ($(this).is(':checked')) {
            parent.prop('checked', true);
            //循环到顶级
            while (dataid.lastIndexOf("-") != 2) {
                dataid = dataid.substring(0, dataid.lastIndexOf("-"));
                parent = $('input[dataid=' + dataid + ']');
                parent.prop('checked', true);
            }
        } else {
            //父级
            if ($('input[dataid^=' + dataid + '-]:checked').length == 0) {
                parent.prop('checked', false);
                //循环到顶级
                while (dataid.lastIndexOf("-") != 2) {
                    dataid = dataid.substring(0, dataid.lastIndexOf("-"));
                    parent = $('input[dataid=' + dataid + ']');
                    if ($('input[dataid^=' + dataid + '-]:checked').length == 0) {
                        parent.prop('checked', false);
                    }
                }
            }
        }
    });
});
</script>

<!--/请在上方写此页面业务相关的脚本-->
{include file="public/footer"}